using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Sis.Entities;

namespace Sis.Repository.Mapping
{
    public class PromotorMap : EntityTypeConfiguration<Promotor>
    {
        public PromotorMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.CodigoPromotor)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.NumPromotor)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Ubigeo)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.CodigoEquifax)
                .IsRequired()
                .HasMaxLength(12);

            this.Property(t => t.Dni)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.Nombres)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.ApPaterno)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.ApMaterno)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Telefono)
                .IsRequired()
                .HasMaxLength(9);

            this.Property(t => t.email)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Direccion)
                .IsRequired()
                .HasMaxLength(500);

            // Table & Column Mappings
            this.ToTable("Promotor");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.CodigoPromotor).HasColumnName("CodigoPromotor");
            this.Property(t => t.NumPromotor).HasColumnName("NumPromotor");
            this.Property(t => t.Ubigeo).HasColumnName("Ubigeo");
            this.Property(t => t.IdIslaVenta).HasColumnName("IdIslaVenta");
            this.Property(t => t.CodigoEquifax).HasColumnName("CodigoEquifax");
            this.Property(t => t.Dni).HasColumnName("Dni");
            this.Property(t => t.Nombres).HasColumnName("Nombres");
            this.Property(t => t.ApPaterno).HasColumnName("ApPaterno");
            this.Property(t => t.ApMaterno).HasColumnName("ApMaterno");
            this.Property(t => t.Genero).HasColumnName("Genero");
            this.Property(t => t.FechaNac).HasColumnName("FechaNac");
            this.Property(t => t.Telefono).HasColumnName("Telefono");
            this.Property(t => t.email).HasColumnName("email");
            this.Property(t => t.Direccion).HasColumnName("Direccion");

            // Relationships
            this.HasRequired(t => t.IslaVenta)
                .WithMany(t => t.Promotors)
                .HasForeignKey(d => d.IdIslaVenta);

        }
    }
}
